import instance from '@/utils/request'

// 获取公告列表
export function getAnnouncements(params) {
    return instance.request({
        method: 'get',
        url: '/api/announcements',
        params,
    })
}

// 获取公告详情
export function getAnnouncementDetail(id) {
    return instance.request({
        method: 'get',
        url: `/api/announcements/${id}`
    })
}

// 创建公告
export function createAnnouncement(data) {
    return instance.request({
        method: 'post',
        url: '/api/announcements',
        data
    })
}

// 更新公告
export function updateAnnouncement(id, data) {
    return instance.request({
        method: 'put',
        url: `/api/announcements/${id}`,
        data
    })
}

// 删除公告
export function deleteAnnouncement(id) {
    return instance.request({
        method: 'delete',
        url: `/api/announcements/${id}`
    })
}

// 批量删除公告
export function batchDeleteAnnouncements(data) {
    return instance.request({
        method: 'post',
        url: '/api/announcements/batch-delete',
        data
    })
}

// 获取最新公告
export function getLatestAnnouncements() {
    return instance.request({
        method: 'get',
        url: '/api/announcements/latest'
    })
}

// 获取公告统计
export function getAnnouncementStats() {
    return instance.request({
        method: 'get',
        url: '/api/announcements/stats'
    })
}